package top.fyxxxx.dbdesign.servlet;

import top.fyxxxx.dbdesign.util.CourseManager;
import top.fyxxxx.dbdesign.util.Manager;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/JoininServlet")
public class JoininServlet extends HttpServlet {
    CourseManager manager= Manager.courseManager();
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        long cid=Long.parseLong(request.getParameter("cid"));
        long uid=(Long)request.getSession().getAttribute("uid");
        if(manager.joinCourse(uid,cid)){
            response.sendRedirect("createClass.jsp?msg=success");
        }else response.sendRedirect("createClass.jsp?msg=fail");
    }
}
